#pragma once
// MESSAGE BUC_RESPONSE PACKING

#define MAVLINK_MSG_ID_BUC_RESPONSE 174

MAVPACKED(
typedef struct __mavlink_buc_response_t {
 float att; /*<  attenuation.*/
 float power; /*<  output power.*/
 float gain; /*<  gain.*/
 float freq; /*<  frequency(ka.MHz).*/
 float res1; /*<  res1.*/
 uint32_t res2; /*<  res2.*/
 int16_t temp; /*<  temperature.*/
 uint8_t status; /*<  work status.*/
 uint8_t cmd; /*<  the cmd of BUC.*/
 uint8_t sw; /*<  open or close.*/
 uint8_t lo; /*<  lo1 or lo2 or lo3 or lo4.*/
}) mavlink_buc_response_t;

#define MAVLINK_MSG_ID_BUC_RESPONSE_LEN 30
#define MAVLINK_MSG_ID_BUC_RESPONSE_MIN_LEN 30
#define MAVLINK_MSG_ID_174_LEN 30
#define MAVLINK_MSG_ID_174_MIN_LEN 30

#define MAVLINK_MSG_ID_BUC_RESPONSE_CRC 58
#define MAVLINK_MSG_ID_174_CRC 58



#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_BUC_RESPONSE { \
    174, \
    "BUC_RESPONSE", \
    11, \
    {  { "status", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_buc_response_t, status) }, \
         { "cmd", NULL, MAVLINK_TYPE_UINT8_T, 0, 27, offsetof(mavlink_buc_response_t, cmd) }, \
         { "sw", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_buc_response_t, sw) }, \
         { "att", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_buc_response_t, att) }, \
         { "lo", NULL, MAVLINK_TYPE_UINT8_T, 0, 29, offsetof(mavlink_buc_response_t, lo) }, \
         { "temp", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_buc_response_t, temp) }, \
         { "power", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_buc_response_t, power) }, \
         { "gain", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_buc_response_t, gain) }, \
         { "freq", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_buc_response_t, freq) }, \
         { "res1", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_buc_response_t, res1) }, \
         { "res2", NULL, MAVLINK_TYPE_UINT32_T, 0, 20, offsetof(mavlink_buc_response_t, res2) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_BUC_RESPONSE { \
    "BUC_RESPONSE", \
    11, \
    {  { "status", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_buc_response_t, status) }, \
         { "cmd", NULL, MAVLINK_TYPE_UINT8_T, 0, 27, offsetof(mavlink_buc_response_t, cmd) }, \
         { "sw", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_buc_response_t, sw) }, \
         { "att", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_buc_response_t, att) }, \
         { "lo", NULL, MAVLINK_TYPE_UINT8_T, 0, 29, offsetof(mavlink_buc_response_t, lo) }, \
         { "temp", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_buc_response_t, temp) }, \
         { "power", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_buc_response_t, power) }, \
         { "gain", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_buc_response_t, gain) }, \
         { "freq", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_buc_response_t, freq) }, \
         { "res1", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_buc_response_t, res1) }, \
         { "res2", NULL, MAVLINK_TYPE_UINT32_T, 0, 20, offsetof(mavlink_buc_response_t, res2) }, \
         } \
}
#endif

/**
 * @brief Pack a buc_response message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param status  work status.
 * @param cmd  the cmd of BUC.
 * @param sw  open or close.
 * @param att  attenuation.
 * @param lo  lo1 or lo2 or lo3 or lo4.
 * @param temp  temperature.
 * @param power  output power.
 * @param gain  gain.
 * @param freq  frequency(ka.MHz).
 * @param res1  res1.
 * @param res2  res2.
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_buc_response_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               uint8_t status, uint8_t cmd, uint8_t sw, float att, uint8_t lo, int16_t temp, float power, float gain, float freq, float res1, uint32_t res2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_BUC_RESPONSE_LEN];
    _mav_put_float(buf, 0, att);
    _mav_put_float(buf, 4, power);
    _mav_put_float(buf, 8, gain);
    _mav_put_float(buf, 12, freq);
    _mav_put_float(buf, 16, res1);
    _mav_put_uint32_t(buf, 20, res2);
    _mav_put_int16_t(buf, 24, temp);
    _mav_put_uint8_t(buf, 26, status);
    _mav_put_uint8_t(buf, 27, cmd);
    _mav_put_uint8_t(buf, 28, sw);
    _mav_put_uint8_t(buf, 29, lo);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BUC_RESPONSE_LEN);
#else
    mavlink_buc_response_t packet;
    packet.att = att;
    packet.power = power;
    packet.gain = gain;
    packet.freq = freq;
    packet.res1 = res1;
    packet.res2 = res2;
    packet.temp = temp;
    packet.status = status;
    packet.cmd = cmd;
    packet.sw = sw;
    packet.lo = lo;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BUC_RESPONSE_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_BUC_RESPONSE;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_BUC_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_CRC);
}

/**
 * @brief Pack a buc_response message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param status  work status.
 * @param cmd  the cmd of BUC.
 * @param sw  open or close.
 * @param att  attenuation.
 * @param lo  lo1 or lo2 or lo3 or lo4.
 * @param temp  temperature.
 * @param power  output power.
 * @param gain  gain.
 * @param freq  frequency(ka.MHz).
 * @param res1  res1.
 * @param res2  res2.
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_buc_response_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   uint8_t status,uint8_t cmd,uint8_t sw,float att,uint8_t lo,int16_t temp,float power,float gain,float freq,float res1,uint32_t res2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_BUC_RESPONSE_LEN];
    _mav_put_float(buf, 0, att);
    _mav_put_float(buf, 4, power);
    _mav_put_float(buf, 8, gain);
    _mav_put_float(buf, 12, freq);
    _mav_put_float(buf, 16, res1);
    _mav_put_uint32_t(buf, 20, res2);
    _mav_put_int16_t(buf, 24, temp);
    _mav_put_uint8_t(buf, 26, status);
    _mav_put_uint8_t(buf, 27, cmd);
    _mav_put_uint8_t(buf, 28, sw);
    _mav_put_uint8_t(buf, 29, lo);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BUC_RESPONSE_LEN);
#else
    mavlink_buc_response_t packet;
    packet.att = att;
    packet.power = power;
    packet.gain = gain;
    packet.freq = freq;
    packet.res1 = res1;
    packet.res2 = res2;
    packet.temp = temp;
    packet.status = status;
    packet.cmd = cmd;
    packet.sw = sw;
    packet.lo = lo;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BUC_RESPONSE_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_BUC_RESPONSE;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_BUC_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_CRC);
}

/**
 * @brief Encode a buc_response struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param buc_response C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_buc_response_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_buc_response_t* buc_response)
{
    return mavlink_msg_buc_response_pack(system_id, component_id, msg, buc_response->status, buc_response->cmd, buc_response->sw, buc_response->att, buc_response->lo, buc_response->temp, buc_response->power, buc_response->gain, buc_response->freq, buc_response->res1, buc_response->res2);
}

/**
 * @brief Encode a buc_response struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param buc_response C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_buc_response_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_buc_response_t* buc_response)
{
    return mavlink_msg_buc_response_pack_chan(system_id, component_id, chan, msg, buc_response->status, buc_response->cmd, buc_response->sw, buc_response->att, buc_response->lo, buc_response->temp, buc_response->power, buc_response->gain, buc_response->freq, buc_response->res1, buc_response->res2);
}

/**
 * @brief Send a buc_response message
 * @param chan MAVLink channel to send the message
 *
 * @param status  work status.
 * @param cmd  the cmd of BUC.
 * @param sw  open or close.
 * @param att  attenuation.
 * @param lo  lo1 or lo2 or lo3 or lo4.
 * @param temp  temperature.
 * @param power  output power.
 * @param gain  gain.
 * @param freq  frequency(ka.MHz).
 * @param res1  res1.
 * @param res2  res2.
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_buc_response_send(mavlink_channel_t chan, uint8_t status, uint8_t cmd, uint8_t sw, float att, uint8_t lo, int16_t temp, float power, float gain, float freq, float res1, uint32_t res2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_BUC_RESPONSE_LEN];
    _mav_put_float(buf, 0, att);
    _mav_put_float(buf, 4, power);
    _mav_put_float(buf, 8, gain);
    _mav_put_float(buf, 12, freq);
    _mav_put_float(buf, 16, res1);
    _mav_put_uint32_t(buf, 20, res2);
    _mav_put_int16_t(buf, 24, temp);
    _mav_put_uint8_t(buf, 26, status);
    _mav_put_uint8_t(buf, 27, cmd);
    _mav_put_uint8_t(buf, 28, sw);
    _mav_put_uint8_t(buf, 29, lo);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BUC_RESPONSE, buf, MAVLINK_MSG_ID_BUC_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_CRC);
#else
    mavlink_buc_response_t packet;
    packet.att = att;
    packet.power = power;
    packet.gain = gain;
    packet.freq = freq;
    packet.res1 = res1;
    packet.res2 = res2;
    packet.temp = temp;
    packet.status = status;
    packet.cmd = cmd;
    packet.sw = sw;
    packet.lo = lo;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BUC_RESPONSE, (const char *)&packet, MAVLINK_MSG_ID_BUC_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_CRC);
#endif
}

/**
 * @brief Send a buc_response message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_buc_response_send_struct(mavlink_channel_t chan, const mavlink_buc_response_t* buc_response)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_buc_response_send(chan, buc_response->status, buc_response->cmd, buc_response->sw, buc_response->att, buc_response->lo, buc_response->temp, buc_response->power, buc_response->gain, buc_response->freq, buc_response->res1, buc_response->res2);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BUC_RESPONSE, (const char *)buc_response, MAVLINK_MSG_ID_BUC_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_CRC);
#endif
}

#if MAVLINK_MSG_ID_BUC_RESPONSE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This varient of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_buc_response_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  uint8_t status, uint8_t cmd, uint8_t sw, float att, uint8_t lo, int16_t temp, float power, float gain, float freq, float res1, uint32_t res2)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;
    _mav_put_float(buf, 0, att);
    _mav_put_float(buf, 4, power);
    _mav_put_float(buf, 8, gain);
    _mav_put_float(buf, 12, freq);
    _mav_put_float(buf, 16, res1);
    _mav_put_uint32_t(buf, 20, res2);
    _mav_put_int16_t(buf, 24, temp);
    _mav_put_uint8_t(buf, 26, status);
    _mav_put_uint8_t(buf, 27, cmd);
    _mav_put_uint8_t(buf, 28, sw);
    _mav_put_uint8_t(buf, 29, lo);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BUC_RESPONSE, buf, MAVLINK_MSG_ID_BUC_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_CRC);
#else
    mavlink_buc_response_t *packet = (mavlink_buc_response_t *)msgbuf;
    packet->att = att;
    packet->power = power;
    packet->gain = gain;
    packet->freq = freq;
    packet->res1 = res1;
    packet->res2 = res2;
    packet->temp = temp;
    packet->status = status;
    packet->cmd = cmd;
    packet->sw = sw;
    packet->lo = lo;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BUC_RESPONSE, (const char *)packet, MAVLINK_MSG_ID_BUC_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_LEN, MAVLINK_MSG_ID_BUC_RESPONSE_CRC);
#endif
}
#endif

#endif

// MESSAGE BUC_RESPONSE UNPACKING


/**
 * @brief Get field status from buc_response message
 *
 * @return  work status.
 */
static inline uint8_t mavlink_msg_buc_response_get_status(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  26);
}

/**
 * @brief Get field cmd from buc_response message
 *
 * @return  the cmd of BUC.
 */
static inline uint8_t mavlink_msg_buc_response_get_cmd(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  27);
}

/**
 * @brief Get field sw from buc_response message
 *
 * @return  open or close.
 */
static inline uint8_t mavlink_msg_buc_response_get_sw(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  28);
}

/**
 * @brief Get field att from buc_response message
 *
 * @return  attenuation.
 */
static inline float mavlink_msg_buc_response_get_att(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  0);
}

/**
 * @brief Get field lo from buc_response message
 *
 * @return  lo1 or lo2 or lo3 or lo4.
 */
static inline uint8_t mavlink_msg_buc_response_get_lo(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  29);
}

/**
 * @brief Get field temp from buc_response message
 *
 * @return  temperature.
 */
static inline int16_t mavlink_msg_buc_response_get_temp(const mavlink_message_t* msg)
{
    return _MAV_RETURN_int16_t(msg,  24);
}

/**
 * @brief Get field power from buc_response message
 *
 * @return  output power.
 */
static inline float mavlink_msg_buc_response_get_power(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  4);
}

/**
 * @brief Get field gain from buc_response message
 *
 * @return  gain.
 */
static inline float mavlink_msg_buc_response_get_gain(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  8);
}

/**
 * @brief Get field freq from buc_response message
 *
 * @return  frequency(ka.MHz).
 */
static inline float mavlink_msg_buc_response_get_freq(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  12);
}

/**
 * @brief Get field res1 from buc_response message
 *
 * @return  res1.
 */
static inline float mavlink_msg_buc_response_get_res1(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  16);
}

/**
 * @brief Get field res2 from buc_response message
 *
 * @return  res2.
 */
static inline uint32_t mavlink_msg_buc_response_get_res2(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint32_t(msg,  20);
}

/**
 * @brief Decode a buc_response message into a struct
 *
 * @param msg The message to decode
 * @param buc_response C-struct to decode the message contents into
 */
static inline void mavlink_msg_buc_response_decode(const mavlink_message_t* msg, mavlink_buc_response_t* buc_response)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    buc_response->att = mavlink_msg_buc_response_get_att(msg);
    buc_response->power = mavlink_msg_buc_response_get_power(msg);
    buc_response->gain = mavlink_msg_buc_response_get_gain(msg);
    buc_response->freq = mavlink_msg_buc_response_get_freq(msg);
    buc_response->res1 = mavlink_msg_buc_response_get_res1(msg);
    buc_response->res2 = mavlink_msg_buc_response_get_res2(msg);
    buc_response->temp = mavlink_msg_buc_response_get_temp(msg);
    buc_response->status = mavlink_msg_buc_response_get_status(msg);
    buc_response->cmd = mavlink_msg_buc_response_get_cmd(msg);
    buc_response->sw = mavlink_msg_buc_response_get_sw(msg);
    buc_response->lo = mavlink_msg_buc_response_get_lo(msg);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_BUC_RESPONSE_LEN? msg->len : MAVLINK_MSG_ID_BUC_RESPONSE_LEN;
        memset(buc_response, 0, MAVLINK_MSG_ID_BUC_RESPONSE_LEN);
    memcpy(buc_response, _MAV_PAYLOAD(msg), len);
#endif
}
